<!DOCTYPE html>
<html lang="en">
	<head>
		<meta charset="utf-8" />
		<title>记忆回廊</title>
		<meta name="viewport" content="width=device-width, initial-scale=1.0" />
		<link rel="stylesheet" href="/static/plugin/ace/css/colorbox.css" />
		<include file="common/tag"/>
	</head>
	<style>
		.yui_row{
			margin-left:-5px;
			margin-right:8px
		}
		body{
			background-color:#fff
		}
		.yui_md{
			margin-left: 10px;
			margin-top: 10px;
			margin-bottom: 10px;
			float: left;
		}
		.yui_rd{
			margin-right: 20px;
			margin-top: 10px;
			margin-bottom: 10px;
			float: right;
		}
		img{
			width: 150px;
			height:150px;
		}
		.yui_page{
			text-align: center;
		}
	</style>
	<body>

	<div class="page-content">
		<div class="page-header">
			<h1>
				记忆深处
				<small>
					<i class="icon-double-angle-right"></i>
					时光呀时光，请慢行吧
				</small>
			</h1>
		</div><!-- /.page-header -->

		<input type="hidden" name="code" value="{$code}"/>
		<div class="yui_md">
			<button class="btn btn-primary" id="yui_add">
				<i class="icon-picture align-top bigger-125"></i>
				上传
			</button>
		</div>

		<div class="yui_md">
			<button class="btn btn-success" id="yui_manager">
				<i class="icon-retweet align-top bigger-125"></i>
				批量管理
			</button>
		</div>

		<div class="yui_md">
			<button class="btn btn-danger" id="yui_all_del">
				<i class="icon-remove align-top bigger-125"></i>
				删除
			</button>
		</div>

		<div class="yui_rd">
			<a href="javascript:location.reload()"><span class="label label-xlg label-primary arrowed arrowed-right">重载</span></a>
		</div>

		<div class="row yui_row">
			<div class="col-xs-12">
				<div class="row">
					<div class="col-xs-12">
						<!-- PAGE CONTENT BEGINS -->

						<div class="row-fluid">
							<ul class="ace-thumbnails">
								<foreach name="data" item="vo">
								<li>
									<a href="{$vo.url}" data-rel="colorbox">
										<img alt="150x150" src="{$vo.url}" />
										<div class="text">
											<div class="inner">于光影中穿行</div>
										</div>
										<div class="tags">
										<span class="label-holder">
											<span class="label label-info arrowed">{$vo.tag}</span>
										</span>

											<span class="label-holder">
											<span class="label label-danger">{$vo.updated_at|date='Y-m-d H:i:s',###}</span>
										</span>
										</div>
									</a>

									<input type="checkbox" class="ace yui_ck" value="{$vo.id}"/>

									<div class="tools tools-top">

										<a class="yui_edit" onclick="yui_edit('{$vo.id}')" >
											<i class="icon-pencil"></i>
										</a>

										<a class="yui_del" onclick="yui_del('{$vo.id}')">
											<i class="icon-remove red"></i>
										</a>
									</div>
								</li>
								</foreach>
							</ul>
						</div><!-- PAGE CONTENT ENDS -->


					</div><!-- /.col -->

				</div><!-- /.row -->
				<div class="row yui_page">
					{$data->render()}
				</div>
			</div>
		</div>

	</div>



		<script src="/static/plugin/ace/js/jquery.colorbox-min.js"></script>
		<script type="text/javascript">
            function yui_edit(id) {
                var url="/index.php/admin/album/album_edit?id="+id;
                var index =layer.open({
                    type: 2,
                    area: ['700px','540px'],
                    title: '修改记忆',
                    content: url
                });
            }

            function yui_del(id) {
                layer.open({
                    title: '提示',
                    content: '确认删除数据'
                    ,yes: function(index, layero){
                        var ids=new Array();
                        ids.push(id);
                        $.post("/index.php/admin/album/album_del",
                            {
                                ids:ids
                            },
                            function(data,status){
                                if (data['code']==1){
                                    layer.open({
                                        title: '提示',
                                        content: '操作成功'
                                        ,yes: function(index, layero){
                                            location.reload();
                                        },cancel: function(){
                                            location.reload();
                                        }
                                    });
                                }else{
                                    layer.msg(data['text']);
                                }
                            }, "json"
                        );
                    }
                });
            }

			$(function() {
                var colorbox_params = {
                    reposition:true,
                    scalePhotos:true,
                    scrolling:false,
                    previous:'<i class="icon-arrow-left"></i>',
                    next:'<i class="icon-arrow-right"></i>',
                    close:'&times;',
                    current:'{current} of {total}',
                    maxWidth:'100%',
                    maxHeight:'100%',
                    onOpen:function(){
                        document.body.style.overflow = 'hidden';
                    },
                    onClosed:function(){
                        document.body.style.overflow = 'auto';
                    },
                    onComplete:function(){
                        $.colorbox.resize();
                    }
                };
                $('.ace-thumbnails [data-rel="colorbox"]').colorbox(colorbox_params);
                $("#cboxLoadingGraphic").append("<i class='icon-spinner orange'></i>");//let's add a custom loading icon

                //新增界面
                $('#yui_add').on('click' , function(){
                    var code=$("input[name='code']").val();
                    var url="/index.php/admin/album/album_add?code="+code;
                    var index =layer.open({
                        type: 2,
                        area: ['700px','480px'],
                        title: '新增记忆',
                        content: url
                    });
                });

                //批量管理
				var flag=true;
				$('#yui_manager').on('click',function () {
				    if (flag){
                        $('.yui_ck').each(function () {
                            $(this).css('opacity',1);
                            $(this).css('position','relative');
                            $(this).prop('checked',true);
                        });
                        flag=false;
					}else{
                        $('.yui_ck').each(function () {
                            $(this).css('opacity',0);
                            $(this).css('position','absolute');
                            $(this).prop('checked',false);
                        });
                        flag=true;
					}
                });

				$('#yui_all_del').on('click',function () {
                    var ids=new Array();
                    $("input[type='checkbox']").each(function(i){
                        if($(this).is(':checked') == true){
                            if ($(this).val()!="on")
                                ids.push($(this).val());
                        }
                    });
                    if (ids.length==0){
                        layer.msg("未选择数据",{time:1000});
                    }else{
                        layer.open({
                            title: '提示',
                            content: '确认批量删除数据'
                            ,yes: function(index, layero){
                                //获取本行id
                                $.post("/index.php/admin/album/album_del",
                                    {
                                        ids:ids
                                    },
                                    function(data,status){
                                        if (data['code']==1){
                                            layer.open({
                                                title: '提示',
                                                content: '操作成功'
                                                ,yes: function(index, layero){
                                                    location.reload();
                                                },cancel: function(){
                                                    location.reload();
                                                }
                                            });
                                        }else{
                                            layer.msg(data['text']);
                                        }
                                    }, "json"
                                );
                            }
                        });
                    }
                });
			})

		</script>
	</body>
</html>
